<?php

class X {
    
}

class_alias('X','Y');
class_alias('Y','Z');
$z = new ReflectionClass('Z');
echo $z->getName(); // X

/*class sql{
    public function select($string){
        echo " select ".$string;
        return $this;
    }
    public function from($string){
        echo " from ".$string;
        return $this;
    }
    public function where($string){
        echo " where ".$string;
        return $this;
    }
    public function order($string){
        echo " order by ".$string;
        return $this;
    }
    public function limit($string){
        echo " limit ".$string;
        return $this;
    }
}
$sql=new sql();
$sql->select("field1")->from("table1")->where("id=1")->order("id desc")->limit("10");*/


/*require("./plan_class.php");


$data = [
    ['date'=>'2011-04-21','wu'=>'test'],
    ['date'=>'2014-04-21','wu'=>'good'],
    ['date'=>'2011-12-22','wu'=>'great'],
    ['date'=>'2012-05-21','wu'=>'hahah'],
    ['date'=>'2013-08-13','wu'=>'test'],
    ['date'=>'2011-04-25','wu'=>'yes'],
    ['date'=>'2014-04-14','wu'=>'no'],
];

$tool=new MyTool();
$tool->setFileExporter( new XmlFile() );
$tool->export($data);

$tool->setFileExporter( new CvsFile() );
$tool->export($data);

$tool->setFileExporter( new JosnFile() );
$tool->export($data);*/

/*namespace watch;
spl_autoload_register(function($className){
	$class_arr=explode("\\",$className);
	echo $class_arr[1].".php";
	include($class_arr[1].".php");
});
$post= new Post();
$post->attach( new \index_notify\SendMail() );
$post->attach( new \index_notify\WriteLog() );
$post->addPost();*/

//主题接口
/*interface Subject {
    public function attach($observer);
    public function detach($observer);
    public function notify();
}*/
//观察者接口
/*interface Observer {
    public function update($subject);
}*/


/*class Post implements SplSubject
{
    protected $_userid = null;
    protected $_ip = null;
    protected $_content = null;

    protected $_observerlist = array();

    function __construct()
    {
        
    }

    public function attach(SplObserver $observer)
    {
        $this->_observerlist[] = $observer;
    }

    public function detach(SplObserver $observer)
    {
        foreach ($this->_observerlist as $key => $value) {
            if ($observer === $value) {
                unset($this->_observerlist[$key]);
            }
        }
    }

    public function notify()
    {
        foreach ($this->_observerlist as $value) {
               $value->update($this); 
        }
    }

    public function addPost()
    {
         $this->notify();
         //do something else...
        
        //
    }
}

class SendMail implements SplObserver{

      public function update(SplSubject $subject){
           echo (date ( 'Y-m-d H:i:s' ) . " 发送邮件功！\r\n");
      }

}
class WriteLog implements SplObserver {

      public function update(SplSubject $subject){
           echo (date ( 'Y-m-d H:i:s' ) . "成功添加日志！\n");
      }

}

$post= new Post();
$post->attach( new SendMail() );
$post->attach( new WriteLog() );
$post->addPost();*/